本次主題是以colab的環境進行學習的,在本篇文章中,我將講解影像辨識的基礎技能在接下來的文章中這些技能將多次出現,先讀過這些語法再繼續去看後面的文章會比較能快速上手喔。依照進度每個禮拜都會記錄不同的影像辨識方法,基本順序會從:
載入雲端硬碟:
from google.colab import drive
drive.mount('/content/drive')
下載mediapipe:
!pip install mediapipe
讀入照片及辨識:
import cv2 as cv
import mediapipe as med
import numpy as np
import matplotlib.pyplot as plt
dr = med.solutions.drawing_utils
obj = med.solutions.objectron
cap = cv.imread('/content/drive/MyDrive/hand/55310111424_C_1.jpg')
img = cap
with obj.Objectron(static_image_mode=False,
max_num_objects=5,
min_detection_confidence=0.5,
min_tracking_confidence=0.99,
model_name='Shoe') as objectron:
img2 = cv.cvtColor(img, cv.COLOR_BGR2RGB)
results = objectron.process(img2)
if results.detected_objects:
for detected_object in results.detected_objects:
dr.draw_landmarks(
img, detected_object.landmarks_2d, obj.BOX_CONNECTIONS)
dr.draw_axis(img, detected_object.rotation,
detected_object.translation)
cap = cv.cvtColor(cv.imread('/content/drive/MyDrive/hand/55310111424_C_1.jpg'), cv.COLOR_BGR2RGB)
plt.imshow(cap,cmap="gray")
plt.show()
img = cv.cvtColor(img, cv.COLOR_BGR2RGB)
plt.imshow(img,cmap="gray")
plt.show()
原始圖片:
實際預測結果:
文章主題一覽:
粗體字為額外更新的文章。